import 'package:exsun_plate_app/common/constant.dart';
import 'package:flutter/material.dart';

class SearchPage extends StatefulWidget {
  @override
  SearchPageState createState() => new SearchPageState();
}

class SearchPageState extends State<SearchPage> {
  TextEditingController searchController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    void jumpToArea() {
      Navigator.of(context).pushNamed('/SearchAreaPage');
    }

    return new Scaffold(
      appBar: new AppBar(
        leading: Builder(builder: (BuildContext context) {
          return IconButton(
            icon: Image.asset('images/search_back.png'),
            onPressed: () {
              Navigator.pop(context);
            },
          );
        }),
        elevation: 0,
        backgroundColor: Colors.transparent,
        brightness: Brightness.light,
        titleSpacing: 0,
        title: Container(
            constraints: BoxConstraints.expand(
              height: 40,
            ),
            decoration: BoxDecoration(
              color: Constants.bgColor,
              borderRadius: new BorderRadius.circular((20.0)),
            ),
            child: Container(
              child: Row(
                children: <Widget>[
                  Expanded(
                    child: TextField(
                        controller: searchController,
                        decoration: InputDecoration(
                          prefixIcon:
                              Image.asset('images/checkcar_map_search.png'),
                          hintText: '请输入关键字',
                          //这个属性可以控制hintText垂直局中
                          contentPadding:
                              const EdgeInsets.symmetric(vertical: 10.0),
                          border: OutlineInputBorder(
                              borderRadius: BorderRadius.circular(5),
                              borderSide: BorderSide.none),
                        )),
                  ),
                  IconButton(
                    icon: Image.asset('images/search_voice.png'),
                    onPressed: () {},
                  ),
                ],
              ),
            )),
        actions: <Widget>[
          Container(
            margin: EdgeInsets.fromLTRB(0, 0, 0, 0),
            width: 80,
            child: Center(
              child: FlatButton(
                child: Text(
                  "确定",
                  style:
                      TextStyle(color: Constants.mainGreenColor, fontSize: 16),
                ),
                colorBrightness: Brightness.dark,
                onPressed: () {},
              ),
            ),
          ),
        ],
      ),
      body: new Container(
        child: Column(
          children: <Widget>[
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: <Widget>[
                GestureDetector(
                  child: Row(
                    children: <Widget>[
                      new Image.asset(
                        'images/search_area_n.png',
                        width: 20,
                        height: 40,
                      ),
                      new Text(
                        '区域',
                      ),
                    ],
                  ),
                  onTap: jumpToArea,
                ),
                new Container(
                  margin: EdgeInsets.fromLTRB(20, 0, 5, 0),
                  height: 25,
                  width: 1.5,
                  color: Constants.divideLineColor,
                ),
                Row(
                  children: <Widget>[
                    new Image.asset(
                      'images/search_company_n.png',
                      width: 20,
                      height: 40,
                    ),
                    new Text(
                      '企业',
                      style: TextStyle(
//                  color: Colors.blue
                          ),
                    ),
                  ],
                ),
                new Container(
                  margin: EdgeInsets.fromLTRB(20, 0, 5, 0),
                  height: 25,
                  width: 1.5,
                  color: Constants.divideLineColor,
                ),
                Row(
                  children: <Widget>[
                    new Image.asset(
                      'images/search_state_n.png',
                      width: 20,
                      height: 40,
                    ),
                    new Text(
                      '状态',
                      style: TextStyle(
//                  color: Colors.blue
                          ),
                    ),
                  ],
                ),
              ],
            ),
            new Expanded(
              child: new Container(
                color: Constants.bgColor,
              ),
            ),
          ],
        ),
      ),
    );
  }

  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  void didUpdateWidget(SearchPage oldWidget) {
    super.didUpdateWidget(oldWidget);
  }

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
  }
}
